#pragma once

#include "fpserialport_global.h"
#include "FpSpDefine.h"
#include <QSerialPort>

class FPSERIALPORT_EXPORT FpSerialPort : public QSerialPort
{
public:
    FpSerialPort(QObject* parent = nullptr);
    FpSerialPort(FpSpCfgData spCfg, QObject* parent = nullptr);

    int SetSerialPort(FpSpCfgData spCfg);
    bool setPortName(const QString& name);
    bool setBaudRate(BaudRate baudRate, Directions directions  = AllDirections);
    bool setDataBits(DataBits dataBits);
    bool setStopBits(StopBits stopBits);
    bool setFlowControl(FlowControl flowControl);
    bool setParity(Parity parity);

    FpSpCfgData GetSerialPortInfo();

private:
    FpSpCfgData _spCfg;
};
